
<table style="width:2100px; margin-left:50px;">
    <tr><td style="width:400px;"> <div style="width:159px; height:159px;float:left"><img src=" <?php echo Yii::app()->getBaseUrl(True) . '/themes/pecb/images/pecb-logo.png'; ?>" title="PECB LOGO" />

            </div></td><td style="width:1600px;"><h1 style="color: #453474;"> PECB</h1> <h3 style="color: #453474;"> Professional Evaluation and Certification Board</h3></td>
    </tr>

    <tr><td style="width:400px;"> 
        </td>
        <td style="text-align:right;width:1600px; vertical-align: top;"><h1 style="width:1600px;font-size: 25px;color: #453474;border-bottom: 1px solid #453474;padding-bottom: 10px;margin: 0px 0 5px 0px;">
                Invoice</h1></td></tr>
    <tr><td style="width:400px;height: 50px;"> 
        </td>
        <td style="height:50px;"></td></tr>
</table>
<hr style="padding-bottom:20px;pad">
<table style="width:2100px; margin-left:50px;">
    <tr><td style="width:2100px;">
            <table>
                <tr><td style="width:1050px;vertical-align: top;">
                        <table  border="0" cellspacing="0" cellpadding="1" style="border:1px solid #DEDEDE; padding:6px; width:900px;">
                            <tr>
                                <td style="background:#555; line-height:40px; text-align:left;width:799px; padding:5px; color:#FFFFFF;width:900px;height:50px;vertical-align: top;" ><strong>Invoice To</strong></td>
                            </tr>
                            <tr>
                                <td style="padding:10px;height:50px;width:900px;"class="fontTextSize">
                                    <p style="height:50px;"><?php echo $userDetails->firstname . "  " . $userDetails->lastname; ?> </p>
                                    <p style="height:50px;">  <?php echo $businessAddress['address1'] . ',  ' . $businessAddress['address2']; ?></p>
                                    <p><?php echo $businessAddress['city'] . ",    " . $userState->name . ",    " . $userCountry->name; ?></p>
                                    <p><?php echo $businessAddress['zip']; ?></p>

                                </td>
                            </tr>
                        </table></td>
                    <td style="width:1050px;vertical-align: top;">
                        <table  border="0" cellspacing="1" cellpadding="2px" style="border:1px solid #DEDEDE; padding:6px; width: 900px">
                            <tr>
                                <td style="background:#555; line-height:40px; text-align:left;width:300px;height:50px; color:#FFFFFF;;vertical-align: top;padding:5px"><strong>Date</strong></td>
                                <td style="padding-left:20px;width:650px;height:50px;vertical-align: top;"><?php echo date('d-m-Y', strtotime($model->invoice_generation_date)); ?></td>
                            </tr>
                            <tr>
                                <td style="height:2px; color:#FFFFFF;"></td>
                                <td style="height:2px; color:#FFFFFF;"></td>
                            </tr>
                            <tr>
                                <td style="background:#555; line-height:40px; text-align:left; width:300px;height:50px; color:#FFFFFF;vertical-align: top;padding:5px"><strong>Invoice No.</strong></td>
                                <td style="padding-left:20px;width:650px;height:50px;vertical-align: top;">PECB_Invoice_<?php echo $model->pecb_user_cert_appl_session_id . $model->id; ?></td>
                            </tr>
                        </table>
                    </td>
                </tr>

                <tr><td  style="width:1000px;">
                    </td >
                    <td style="width:1050px;vertical-align: top;"><table border="0" cellspacing="0" cellpadding="0" style="border:1px solid #DEDEDE; padding:6px; margin:10px 0 0 0;">
                            <tr align="left">
                                <td  style="background:#555; line-height:40px; text-align:left; padding-left:10px; color:#FFFFFF; width:480px;height: 50px;vertical-align: top;padding:5px"><strong>Terms</strong></td>
                                <td  style="background:#555; line-height:40px; text-align:left; padding-left:10px; color:#FFFFFF;width:505px;height: 50px;vertical-align: top;padding:5px"><strong>Due Date</strong></td>
                            </tr>
                            <tr>
                                <td style="height:2px; color:#FFFFFF;"></td>
                                <td style="height:2px; color:#FFFFFF;"></td>
                            </tr>
                            <tr align="center"> 
                                <td style=" text-align: left;height: 20px"class="fontTextSize">Net <?php echo $acoountRefTime->days;?></td>
                                <td style=" text-align: left;height: 20px"class="fontTextSize"><?php echo date('d-m-Y', strtotime($model->invoice_generation_date . "+$acoountRefTime->days days")); ?></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td></tr>
    <tr>
        <td style="height:10px; border-bottom:1px solid #DEDEDE;color:#FFFFFF;"></td>

    </tr>
    <tr><td style="width:2100px;vertical-align: top;" > 

            <table>
                <tr >
                    <td style="background:#555; line-height:40px; text-align:left; padding-left:10px; color:#FFFFFF; width:1000px;height: 50px;vertical-align: top;padding:5px"><strong>Description</strong></td>
                    <td  style="background:#555; line-height:40px; text-align:left; padding-left:30px; color:#FFFFFF;width:270px;height: 50px;vertical-align: top;padding:5px"><strong>&nbsp;&nbsp;&nbsp;Qty</strong></td>
                    <td style="background:#555; line-height:40px; text-align:center; padding-left:10px; color:#FFFFFF;width:350px;height: 50px;vertical-align: top;padding:5px"><strong>Rate</strong></td>
                    <td style="background:#555; line-height:40px; text-align:center; padding-left:10px; color:#FFFFFF;width:350px;height: 50px;vertical-align: top;padding:5px"><strong>Amount</strong></td>
                </tr>
                <?php
                $OrganisationInformation = OrganisationInformation::model()->findByPk(1);
                if (!empty($userCerTiId)) {
                    $userApplicantIds = explode(',', $userCerTiId->user_cert_application_id);
                    $certificatenameCurrency = '';
                    ?>
                    <tr align="center">
                        <td align="left"  style="padding:10px 0;width:1000px;" class="fontTextSize" >
                            <?php
                            foreach ($userApplicantIds as $userApplicantId) {
                                $certificatename = PaymentDetails::getCertificateName($userApplicantId);
                                echo '<p>' . $certificatename['name'] . '</p>';
                            }

                            echo '<br/><br/>';
                            $userTextInfos = InvoiceTax::GetUserTaxInformation($userCountry->id, $userState->id);
                            if (!empty($userTextInfos)) {
                                foreach ($userTextInfos as $userTextInfo) {
                                    echo '<p>' . $userTextInfo['tax_name'] . ' on sales</p>';
                                }
                            }
                            ?> 

                        </td>
                        <td style="width:270px;height: 50px; text-align:left;vertical-align: middle;padding-left:30px;" class="fontTextSize">&nbsp;&nbsp;<?php echo count($userApplicantIds); ?></td>
                        <td style="width:350px;height: 50px;vertical-align: top;text-align:center;"class="fontTextSize">
                            <?php
                            foreach ($userApplicantIds as $userApplicantId) {
                                $certificatePrice = PaymentDetails::getCertificateName($userApplicantId);
                                echo '<p>' . PaymentDetails::formatInIndianStyle($certificatePrice['price']) . '</p>';
                            }
                            ?>  
                            <br><br>
                            <?php
                            $userTextsPrices = InvoiceTax::GetUserTaxInformation($userCountry->id, $userState->id);
                            if (!empty($userTextsPrices)) {
                                foreach ($userTextsPrices as $userTextsPrice) {
                                    echo '<p>' . $userTextsPrice['tax_amount'] . ' %</p>';
                                }
                            }
                            ?>                    
                        </td>
                        <td style="width:350px; vertical-align: top;text-align:center;"class="fontTextSize">
                            <?php
                            $certificateTotalPrice = 0;
                            foreach ($userApplicantIds as $userApplicantId) {
                                $certificatePricess = PaymentDetails::getCertificateName($userApplicantId);
                                $certificateTotalPrice = $certificateTotalPrice + $certificatePricess['price'];
                                echo '<p>' . PaymentDetails::formatInIndianStyle($certificatePricess['price']) . '</p>';
                                $certificatenameCurrency = $certificatename['currency'];
                            }
                            ?>
                            <br><br>
                            <?php
                            $userTexts = InvoiceTax::GetUserTaxInformation($userCountry->id, $userState->id);
                            $totalTaxPrice = '';
                            if (!empty($userTexts)) {

                                foreach ($userTexts as $userText) {
                                    $totalTaxPrices = InvoiceTax::getTaxCalculation($certificateTotalPrice, $userText['tax_amount']);
                                    echo '<p>' . PaymentDetails::formatInIndianStyle($totalTaxPrices) . '</p>';
                                    $totalTaxPrice = $totalTaxPrice + $totalTaxPrices;
                                }
                            }
                            ?> 

                        </td>
                    </tr>
                <?php }
                ?> 
                <tr><td style="height: 50px;width:1000px;border-bottom:1px solid #DEDEDE;"class="fontTextSize"></td>
                    <td style="height: 50px;width:270px;border-bottom:1px solid #DEDEDE;"></td>
                    <td style="height: 50px;width:350px;border-bottom:1px solid #DEDEDE;"></td>
                    <td style="height: 50px;width:350px;border-bottom:1px solid #DEDEDE;"></td></tr>
                <tr>
                    <td  style="padding:10px 0;width: 1000px;vertical-align: top;">

                        <?php
                        $taxNos = InvoiceTax::GetUserTaxInformation($userCountry->id, $userState->id);

                        if (!empty($taxNos)) {
                            foreach ($taxNos as $taxNo) {
                                if (!empty($taxNo['tax_no'])) {
                                    echo '<p><strong>' . $taxNo['tax_name'] . '.:</strong><span class="fontTextSize"> ' . $taxNo['tax_no'] . '</span> </p>';
                                }
                            }
                        }
                        ?>
                        <br/><br/>
                        <p style="height:2px;"></p>
                    </td>
                    <td style="border-bottom:1px solid #DEDEDE;text-align: left;width:270px; vertical-align: middle"></td>
                    <td style="border-bottom:1px solid #DEDEDE; width:350px;height: 70px;text-align: left; vertical-align: middle">

                        <?php
                        $totalNewPrice = $totalTaxPrice + $certificateTotalPrice;
                        if ($model->amount != $totalNewPrice) {
                            ?>
                            <p>Total (After Discount):</p>
                            <?php
                        } else {
                            echo '<p>Total:</p><br>';
                        }
                        ?>

                    </td>
                    <td style="border-bottom:1px solid #DEDEDE;width:350px;vertical-align: middle;text-align: left;"> 
                        <?php
                        if ($model->amount != $totalNewPrice) {
                            echo ' <p><del>' . $certificatenameCurrency . '  ' . PaymentDetails::formatInIndianStyle($totalNewPrice) . ' </del></p><br>';
                            echo '<p>' . $certificatenameCurrency . ' ' . PaymentDetails::formatInIndianStyle($model->amount) . '</p>';
                        } else {

                            echo $certificatenameCurrency . '  ' . PaymentDetails::formatInIndianStyle($totalNewPrice);
                        }
                        ?><br/> <br/></td>
                </tr>

                <tr><td style="height: 50px;width:1000px;"class="fontTextSize"></td><td style="height: 50px;width:270px;"></td>
                    <td style="height: 50px;width:350px;"></td><td style="height: 50px;width:350px;"></td></tr>

                <tr align="center">
                    <td align="left" style="border-bottom:1px solid #DEDEDE;  padding:10px 0;width: 1000px;height: 70px;vertical-align: top;">
                        <p class="fontTextSize">Payment is due in <?php echo $acoountRefTime->days;?> days, and the montly interest of 1.5% </p><p class="fontTextSize">will be charged for
                            the late payment.</p>
                    </td>
                    <td style="border-bottom:1px solid #DEDEDE;width: 270px;height: 70px;vertical-align: top;">&nbsp;</td>
                    <td style="border-bottom:1px solid #DEDEDE;width: 350px;height: 70px;vertical-align: top;text-align: left;">Payments/Credits:</td>
                    <td style="border-bottom:1px solid #DEDEDE;width: 350px;height: 70px;vertical-align: top;text-align: left;"><?php echo $certificatenameCurrency ?> 0.00</td>
                </tr>
                <tr><td style="height: 50px;width:1000px;"class="fontTextSize"></td><td style="height: 50px;width:270px;"></td>
                    <td style="height: 50px;width:350px;"></td><td style="height: 50px;width:350px;"></td></tr>
                <tr align="center">
                    <td align="left" style=" padding:10px 0;width: 1000px;height: 70px;vertical-align: top;">
                        <p class="fontTextSize">We would appreciate it if you could include the invoice  </p>
                        <p class="fontTextSize">number when you make the payment. Thank you.</p>
                    </td>
                    <td style="width: 270px;height: 70px;">&nbsp;</td>
                    <td style="width: 350px;height: 70px;text-align: left;">Balance Due:</td>
                    <td style="width: 350px;height: 70px; text-align: left;"><?php
                        if ($model->amount != $totalNewPrice) {

                            echo '<p>' . $certificatenameCurrency . ' ' . PaymentDetails::formatInIndianStyle($model->amount) . '</p>';
                        } else {
                            echo $certificatenameCurrency . '  ' . PaymentDetails::formatInIndianStyle($totalNewPrice);
                        }
                        ?></td>
                </tr>

                <tr><td style="height: 50px;width:1000px;border-bottom:1px solid #DEDEDE;"class="fontTextSize"></td><td style="height: 50px;width:270px;border-bottom:1px solid #DEDEDE;"></td>
                    <td style="height: 50px;width:350px;border-bottom:1px solid #DEDEDE;"></td><td style="height: 50px;width:350px;border-bottom:1px solid #DEDEDE;"></td></tr>
            </table></td></tr>
    <tr><td style="width:2100px;height: 50px;" ></td></tr>

    <tr><td style="width:2100px;border-bottom: 1px solid #DEDEDE;padding-bottom: 50px;" >
            <table  border="0" align="center" cellpadding="0" cellspacing="0" style="margin:10px 0 0 0;">
                <tr>
                    <td  align="left" valign="top" style="width:1000px;">
                        <table border="0" cellspacing="0" cellpadding="0" style="border:1px solid #DEDEDE; padding:6px;">
                            <tr>
                                <td style="background:#555; line-height:40px; text-align:left;width:950px;padding:8px; color:#FFFFFF; height: 40px;vertical-align: top"><strong> Payable to PECB. via bank transfer /Cheque at:</strong></td>
                            </tr>
                            <tr>
                                <td style=" padding:10px 0;" class="fontTextSize">
                                    <?php echo $OrganisationInformation->bank_details; ?>





                                </td>
                            </tr>
                        </table>
                    </td>
                    <td align="right" valign="top" style="width:1000px;">
                        <table  border="0" cellspacing="0" cellpadding="0" style="border:1px solid #DEDEDE; padding:6px;">
                            <tr>
                                <td style="background:#555;  text-align:left;width:950px; padding:8px; color:#FFFFFF;height: 40px;vertical-align: top"><strong>Or send your cheque to: </strong></td>
                            </tr>
                            <tr>
                                <td style=" padding:10px 0;text-align: left;" class="fontTextSize">
                                    <?php echo $OrganisationInformation->pecb_address; ?>


                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>

        </td></tr>
    <tr><td style="width:2100px;height: 50px;" ></td></tr>

</table>



<div class="clr"></div>

<style>
    .fontTextSize{
        font-size:11px;font-weight: normal;
    }
</style>